//
//  HWManagementViewController.m
//  HWPromoteProjectAPP
//
//  Created by 陈道斌 on 2020/1/20.
//  Copyright © 2020 陈道斌. All rights reserved.
//

#import "HWManagementViewController.h"
#import "HWManagementTableViewCell.h"
#import "HWMygameYouXiViewController.h"
#import "HWApplyGameViewController.h" // 申请游戏
#import "HWDividedintoProportionViewController.h" //分成比例
#import "MyOfflineViewController.h"  // 我的下线
#import "HWRegistrationStatisticsViewController.h" // 注册统计
#import "HWTopupStatisticsViewController.h"  // 充值统计
#import "HWTixianguanliViewController.h"  // 提现管理
#import "HWRoleSummaryViewController.h" // 角色汇总
#import "HWtuiguanpanhangbangViewController.h" // 排行榜
#import "HWtianjiangxianxiangController.h"
#import "HWDiscountDaiChunViewController.h"
#import "HWPromoteGameViewController.h"
#import "HWApplyjiesuanViewController.h"
#import "HWBillingDetailsViewController.h"
#import "HWDividedIntoViewController.h"


 



@interface HWManagementViewController ()<UITableViewDataSource,UITableViewDelegate,HWManagementTableViewCellDelegate>

@property(strong,nonatomic) UITableView *mainTabelView;
@property(strong,nonatomic) NSMutableArray *dataMutableArr;



@end

@implementation HWManagementViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor blueColor];
    
    [self setupUI];
    
    //发送网络请求
    [self sendNetworkRequest];
    
    
}


- (UITableView *)mainTabelView {
    
    if (_mainTabelView == nil) {
        _mainTabelView = [[UITableView alloc]initWithFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStylePlain];
        _mainTabelView.delegate = self;
        _mainTabelView.dataSource = self;
        _mainTabelView.backgroundColor = beijingyanSe;
        _mainTabelView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    }
    return _mainTabelView;
    
    
    
    

    
}









// 设置常用的属性

- (void)setUpchangyongshuxng {
    
    
    self.navigationItem.title = @"管理";
    self.view.backgroundColor = beijingyanSe;

    

}


// 设置UI

- (void)setupUI {
    
    [self.view addSubview:self.mainTabelView];
    
    
    
    
}





// 发送网络请求
- (void)sendNetworkRequest {
    
    
    
     
         NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
         NSString *uid =  [HWLocallyStoredData getLoginUserID];
         NSString *signStr = [NSString stringWithFormat:@"%@%@%@",uid,tStr,@"adesxloksy13s98adv"];
         NSString  *signStrMd5  =   [WMUtil md5HexDigest:signStr];
         NSDictionary *parametes = @{      @"ios" : @"1",
                                      @"ct" : @"app",
                                        @"ac" : @"guanli",
                                        @"t" : tStr,
                                        @"uid":uid,
                                        @"sign" :signStrMd5
                                        };
        
        
            [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
                  
                 

                  NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
                  if ([codeStr intValue] == 1) {
                 
                         NSLog(@"%@",response);
                      
                      self.dataMutableArr =   [response[@"data"] mutableCopy];
                      [self.mainTabelView reloadData];
                      
                      
                      
                      
                       
                  } else {
                      
                    [MBProgressHUD showError:response[@"message"]];
                                    
                
                      
                  }
                  
             
                  
              } failure:^(NSString *error) {
                 // [SVProgressHUD dismiss];
                  
                   [MBProgressHUD showSuccess:@"登录失败"];
                  [MBProgressHUD hideHUD];
                  
                  
              }];
        
    
    
    
    
    
    
    
}




- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    
    return  self.dataMutableArr.count;
    
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *cellID = @"cellID";
    
    HWManagementTableViewCell *cell =  [tableView dequeueReusableCellWithIdentifier:cellID];

    if (!cell) {
        cell = [[HWManagementTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];

    }
    
    cell.delegate = self;
    
    
    cell.selectionStyle  = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor whiteColor];
    cell.dihangStr = [NSString stringWithFormat:@"%ld",indexPath.row];
    cell.dataDic = self.dataMutableArr[indexPath.row];
    return  cell;
    
    
    
    
    
    
}



- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
     
    
     return  65+47+20;
    
    return  132;
    
    
    
    
}


#pragma mark -------- HWManagementTableView


- (void)HWManagementTableViewCellshuju:(NSDictionary *)dic {
    
    
    NSLog(@"%@",dic);
    
    NSString *type = [NSString stringWithFormat:@"%@",dic[@"type"]];
    
    if ([type isEqualToString:@"8"]) {
        
        HWMygameYouXiViewController *Mygame = [[HWMygameYouXiViewController alloc]init];
        [self.navigationController pushViewController:Mygame animated:YES];
        
        
         
    }else if ([type isEqualToString:@"2"]) {
        HWApplyGameViewController *ApplyGame = [[HWApplyGameViewController alloc]init];
        [self.navigationController pushViewController:ApplyGame animated:YES];
        
        
        
    }else if ([type isEqualToString:@"9"]) {
        
        HWDividedintoProportionViewController *fengbilei = [[HWDividedintoProportionViewController alloc]init];
        [self.navigationController pushViewController:fengbilei animated:YES];
        
        
        
        
        
    }else if ([type isEqualToString:@"10"]) {
        
        
        MyOfflineViewController *MyOffline = [[MyOfflineViewController alloc]init];
        [self.navigationController pushViewController:MyOffline animated:YES];
        
        
        
        
    }else if ([type isEqualToString:@"11"]) {
        
        
        
        HWtianjiangxianxiangController *tianji = [[HWtianjiangxianxiangController alloc]init];
        [self.navigationController pushViewController:tianji animated:YES];
        
        
        
        
        
    }else if ([type isEqualToString:@"12"]) {
        
        HWTixianguanliViewController *tixian = [[HWTixianguanliViewController alloc]init];
        [self.navigationController pushViewController:tixian animated:YES];
        
        
        
        
        
    }else if ([type isEqualToString:@"13"]) {
        
        
        HWRegistrationStatisticsViewController *Registration = [[HWRegistrationStatisticsViewController alloc]init];
        [self.navigationController pushViewController:Registration animated:YES]; 
        
        
        
    }else if ([type isEqualToString:@"14"]) {
        
        HWTopupStatisticsViewController *Tc = [[HWTopupStatisticsViewController alloc]init];
        [self.navigationController pushViewController:Tc animated:YES];
        
        
        
        
        
        
        
    }else if ([type isEqualToString:@"15"]) {
        
        
        HWRoleSummaryViewController *RoleSummary = [[HWRoleSummaryViewController alloc]init];
        [self.navigationController pushViewController:RoleSummary animated:YES];
        
        
        
        
    }else if ([type isEqualToString:@"16"]) {
        
        
        HWtuiguanpanhangbangViewController *uiguanpan = [[HWtuiguanpanhangbangViewController alloc]init];
        [self.navigationController pushViewController:uiguanpan animated:YES];
        
        
        
        
    } else if ([type intValue] == 1) {
        
        HWPromoteGameViewController *promo = [[HWPromoteGameViewController alloc]init];
        [self.navigationController pushViewController:promo animated:YES];
        
        
        
         
    } else if ([type intValue] == 2) {
        
        
        HWApplyGameViewController *ApplyGame = [[HWApplyGameViewController alloc]init];
        [self.navigationController pushViewController:ApplyGame animated:YES];
        
        
    }else if ([type intValue] == 3) {
        
        
        HWDiscountDaiChunViewController *dicci = [[HWDiscountDaiChunViewController alloc]init];
        [self.navigationController pushViewController:dicci animated:YES];
        
        

        
        
    }else if ([type intValue] == 4) {
        
        
        HWApplyjiesuanViewController *Applyjiesuan = [[HWApplyjiesuanViewController  alloc]init];
        
        
        [self.navigationController pushViewController:Applyjiesuan animated:YES];
        
        
        
    }else if ([type intValue] == 5) {
        
        HWBillingDetailsViewController *bill = [[HWBillingDetailsViewController alloc]init];
        
        
        [self.navigationController pushViewController:bill animated:YES];
        
        
        
    }else if ([type intValue] == 10) {
        
        
             MyOfflineViewController *myoff = [[MyOfflineViewController alloc]init];
             [self.navigationController pushViewController:myoff animated:YES];
        
        
    }else if ([type intValue] == 7) {
        
     
        HWDividedIntoViewController *DividedInto = [[HWDividedIntoViewController alloc]init];
        [self.navigationController pushViewController:DividedInto animated:YES];
        
        
    }else if ([type intValue] == 8) {
        
        
    
        
        
    }
    
    
    
    
    
    
}





@end
